home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / c / ExtrasLib.lha / ExtrasLib / Source / CopyString.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-30  |  991 b   |  53 lines

  1. #include <exec/types.h>
  2. #include <proto/exec.h>
  3. #include <string.h>
  4.  
  5. #include <clib/extras/string_protos.h>
  6.  
  7. /****** extras.lib/CopyString ******************************************
  8. *
  9. *   NAME
  10. *       CopyString -- Copy a string
  11. *
  12. *   SYNOPSIS
  13. *       newstring = CopyString(Source, MemFlags)
  14. *
  15. *       STRPTR CopyString(STRPTR, ULONG);
  16. *
  17. *   FUNCTION
  18. *       Allocates memory using AllocVec and copies a string.
  19. *
  20. *   INPUTS
  21. *       Source - the source string to copy
  22. *       MemFlags - Memory flags see exec.library/AllocVec()
  23. *
  24. *   RESULT
  25. *       String pointer or NULL. 
  26. *
  27. *   NOTES
  28. *       newstring must be freed with FreeVec.
  29. *
  30. *   SEE ALSO
  31. *     exec.library/AllocVec(), exec.library/FreeVec()
  32. *
  33. ******************************************************************************
  34. *
  35. */
  36.  
  37.  
  38. STRPTR CopyString(STRPTR Source,ULONG MemFlags)
  39. {
  40.   STRPTR str;
  41.   
  42.   str=0;
  43.   if(Source)
  44.   {
  45.     if(str=AllocVec(strlen(Source)+1,MemFlags))
  46.     {
  47.       strcpy(str,Source);
  48.     }
  49.   }
  50.  
  51.   return(str);
  52. }
  53.